package net.junaoki.action;

import java.util.List;

import net.junaoki.persistence.Table1;
import net.junaoki.persistence.Table1Dao;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("json-default")
public class GetTable1Action extends ActionSupport{
    
    private static final long serialVersionUID = 1L;

    private Table1[] result;

    @Override
    @Action(value="GetTable1", results = {
            @Result(name = SUCCESS, type = "json", params={"root", "result"})
	    }
    )
    public String execute(){
        
        Table1Dao dao = new Table1Dao();
        List<Table1> table1List = dao.get();
        setResult(table1List.toArray(new Table1[0]));


        return SUCCESS;
    }

    public Table1[] getResult() { return result; }
    public void setResult(Table1[] result) { this.result = result; }

}
